package com.story.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.story.dao.ISessionDao;
import com.story.domain.Page;
import com.story.domain.SessionInfo;
import com.story.service.ISessionService;
@Service("sessionService")
public class SessionServiceImpl implements ISessionService {
	@Autowired
	private ISessionDao sessionDao;
	@Override
	public void create(SessionInfo info) {
		sessionDao.addSession(info);
	}
	@Override
	public void delete(String sessionid) {
		sessionDao.deleteSessionById(sessionid);		
	}
	@Override
	public void update(String username,String session,Date lastAccessTime,String sessionid) {
		sessionDao.updateSessionById(username,session,lastAccessTime,sessionid);	
	}
	@Override
	public SessionInfo querySessionById(String sessionid) {
		return sessionDao.findOneById(sessionid);
	}
	@Override
	public List<SessionInfo> querySessionsById(String sessionid) {
		return sessionDao.findSomeById(sessionid);
	}
	@Override
	public List<SessionInfo> findAll() {
		return sessionDao.findAll();
	}
	@Override
	public Integer totalCount() {
		return sessionDao.totalCount();
	}
	@Override
	public List<SessionInfo> findSomeByLimit(Page page) {
		return sessionDao.findSomeByLimit(page);
	}
	@Override
	public void updateSessionWithLogout(Date quitTime, Boolean status,
			String sessionid) {
		sessionDao.updateSessionWithLogout(quitTime, status, sessionid);
		
	}
	@Override
	public void updateSessionWithRead(Date lastAccessTime, String sessionid) {
		sessionDao.updateSessionWithRead(lastAccessTime, sessionid);		
	}

}
